<div id="tab9" class="tab">
    <div class="tab-labels">
        <div class="xian"></div>
        三者人伤
    </div>
    <div id="div2">
        <table class="layui-table" id="tabProduct6">
            <tr style="background:#4e73df;color: #fff;" class="ys">
                <td style="width: 66px;">选择</td>
                <td>姓名</td>
                <td>性别</td>
                <td>年龄</td>
                <td>户籍性质</td>
                <td>医疗机构</td>
                <td>病案号</td>
                <td>金额</td>
                <td>核价金额</td>
                <td>备注</td>
                <td style="width: 66px;">操作</td>
            </tr>
            {empty name="sanren"}
            <tr>
                <td><input type="checkbox" style="width: 15px;height: 15px;display: block;" name="id" readonly value="">
                </td>
                <td><input type="text" name="name" readonly></td>
                <td><input type="text" name="sex" readonly></td>
                <td><input type="text" name="age" readonly></td>
                <td><input type="text" name="quality" readonly></td>
                <td><input type="text" name="nuit" readonly></td>
                <td><input type="text" name="number" readonly></td>
                <td><input type="text" name="money" readonly></td>
                <td><input type="text" name="hejia" readonly></td>
                <td><input type="text" name="beizhu" readonly></td>
                <td></td>
            </tr>
            {/empty}
            {volist name='sanren' id="sanrens"}
            <tr>
                <td><input type="checkbox" style="width: 15px;height: 15px;display: block;" name="id" readonly
                           value="{$sanrens.id}"></td>
                <td><input type="text" name="name" readonly value="{$sanrens.name}" onclick="openDialogs2({$sanrens.id})"
                           style='text-decoration: underline;color:blue;cursor: pointer;'></td>
                <td><input type="text" name="sex" readonly value="{$sanrens.sex}"></td>
                <td><input type="text" name="age" readonly value="{$sanrens.age}"></td>
                <td><input type="text" name="quality" readonly value="{$sanrens.quality}"></td>
                <td><input type="text" name="nuit" readonly value="{$sanrens.nuit}"></td>
                <td><input type="text" name="number" readonly value="{$sanrens.number}"></td>
                <td><input type="text" name="money" readonly value="{$sum}"></td>
                <td><input type="text" name="hejia" readonly value="{$hd_sum}"></td>
                <td><input type="text" name="beizhu" readonly value="{$sanrens.beizhu}"></td>
                <td></td>
            </tr>
            {/volist}
        </table>
        <table class="layui-table" id="he6">
            <tr>
                <td>小计</td>
                <td><input type="text" readonly></td>
                <td><input type="text" readonly></td>
                <td><input type="text" readonly></td>
                <td><input type="text" readonly></td>
                <td><input type="text" readonly></td>
                <td><input type="text" readonly></td>
                <td><input type="text" readonly></td>
                <td><input type="text" value="{$sum}" id="sanren_money" name="sanren_money"></td>
                <td><input type="text" value="{$hd_sum}" id="sanren_hejia" name="sanren_hejia"></td>
                <td><input type="text" readonly></td>
                <td><input type="text" readonly></td>
            </tr>
        </table>
        <!--<p>汇总</p>-->
        <div class="conts">
            <div class="input">
                <span>费用合计</span>
                <input type="text" readonly value="{$row.sr_heji}" name="sr_heji" id="sr_heji_1">
            </div>
        </div>
        <div class="conts">
            <div class="input dong">
                <span>诉讼费</span>
                <input type="text" id="sanren_susong" oninput="jisuan_money(this)" value="{$row.sanren_susong}"
                       name="sanren_susong">
            </div>
            <div class="input dong">
                <span>鉴定费</span>
                <input type="text" id="sanren_jianding" oninput="jisuan_money(this)" value="{$row.sanren_jianding}"
                       name="sanren_jianding">
            </div>
            <div class="input dong">
                <span>公估费</span>
                <input type="text" id="sanren_gonggu" oninput="jisuan_money(this)" value="{$row.sanren_gonggu}"
                       name="sanren_gonggu">
            </div>
            <div class="input dong">
                <span>住宿费</span>
                <input type="text" id="sanren_zhusu" oninput="jisuan_money(this)" value="{$row.sanren_zhusu}"
                       name="sanren_zhusu">
            </div>
            <div class="input dong">
                <span>路桥费</span>
                <input type="text" id="sanren_luqiao" oninput="jisuan_money(this)" value="{$row.sanren_luqiao}"
                       name="sanren_luqiao">
            </div>
            <div class="input dong">
                <span>燃油费</span>
                <input type="text" id="sanren_ranyou" oninput="jisuan_money(this)" value="{$row.sanren_ranyou}"
                       name="sanren_ranyou">
            </div>
            <div class="input dong">
                <span>其他</span>
                <input type="text" id="sanren_qita" oninput="jisuan_money(this)" value="{$row.sanren_qita}"
                       name="sanren_qita">
            </div>
            <div class="input dong">
                <span>合计</span>
                <input type="text" id="sanren_heji" value="{$row.sanren_heji}" name="sanren_heji">
            </div>
        </div>
        <div class="conts">
            <div class="input dong">
                <span>诉讼费</span>
                <input readonly type="text" id="hd_sanren_susong" value="{$sanren[0]['hd_susong_fee']}"
                       name="hd_sanren_susong">
            </div>
            <div class="input dong">
                <span>鉴定费</span>
                <input readonly type="text" id="hd_sanren_jianding" value="{$sanren[0]['hd_jianding_fee']}"
                       name="hd_sanren_jianding">
            </div>
            <div class="input dong">
                <span>公估费</span>
                <input readonly type="text" id="hd_sanren_gonggu" value="{$sanren[0]['hd_gonggu_fee']}"
                       name="hd_sanren_gonggu">
            </div>
            <div class="input dong">
                <span>住宿费</span>
                <input readonly type="text" id="hd_sanren_zhusu" value="{$sanren[0]['hd_zhusu_fee']}"
                       name="hd_sanren_zhusu">
            </div>
            <div class="input dong">
                <span>路桥费</span>
                <input readonly type="text" id="hd_sanren_luqiao" value="{$sanren[0]['hd_luqiao_fee']}"
                       name="hd_sanren_luqiao">
            </div>
            <div class="input dong">
                <span>燃油费</span>
                <input readonly type="text" id="hd_sanren_ranyou" value="{$sanren[0]['hd_ranyou_fee']}"
                       name="hd_sanren_ranyou">
            </div>
            <div class="input dong">
                <span>其他</span>
                <input readonly type="text" id="hd_sanren_qita" value="{$sanren[0]['hd_qita_fee']}"
                       name="hd_sanren_qita">
            </div>
            <div class="input dong">
                <span>合计</span>
                <input readonly type="text" id="hd_sanren_heji"
                       value="{$sanren[0]['hd_susong_fee']+$sanren[0]['hd_jianding_fee']+$sanren[0]['hd_gonggu_fee']+$sanren[0]['hd_zhusu_fee']+$sanren[0]['hd_luqiao_fee']+$sanren[0]['hd_ranyou_fee']+$sanren[0]['hd_qita_fee']}"
                       name="hd_sanren_heji">
            </div>
        </div>
        <div class="conts" style="text-align:center;">
            <button type="button" onclick="baocun_tian3(this)">保存</button>
        </div>
        <script>
            function jisuan_money(obj) {
                // var parent = $(obj).closest('.conts');
                var sanren_susong = Number($('#sanren_susong').val());
                var sanren_jianding = Number($('#sanren_jianding').val());
                var sanren_gonggu = Number($('#sanren_gonggu').val());
                var sanren_zhusu = Number($('#sanren_zhusu').val());
                var sanren_luqiao = Number($('#sanren_luqiao').val());
                var sanren_ranyou = Number($('#sanren_ranyou').val());
                var sanren_qita = Number($('#sanren_qita').val());

                var total = sanren_susong + sanren_jianding + sanren_gonggu + sanren_zhusu + sanren_luqiao + sanren_ranyou + sanren_qita;
                if (isNaN(total)) total = 0;
                $('#sanren_heji').val(total.toFixed(2));
            }

            function baocun_tian3(sub) {
                var id = {$orderid};
                var sanren_susong = $("#sanren_susong").val();
                var sanren_jianding = $("#sanren_jianding").val();
                var sanren_gonggu = $("#sanren_gonggu").val();
                var sanren_zhusu = $("#sanren_zhusu").val();
                var sanren_luqiao = $("#sanren_luqiao").val();
                var sanren_ranyou = $("#sanren_ranyou").val();
                var sanren_qita = $("#sanren_qita").val();
                var sanren_heji = $("#sanren_heji").val();

                $.ajax({
                    url: "{:url('bushen/lisuan/baocun_tian3')}",
                    data: {
                        id: id,
                        sanren_susong: sanren_susong,
                        sanren_jianding: sanren_jianding,
                        sanren_gonggu: sanren_gonggu,
                        sanren_zhusu: sanren_zhusu,
                        sanren_luqiao: sanren_luqiao,
                        sanren_ranyou: sanren_ranyou,
                        sanren_qita: sanren_qita,
                        sanren_heji: sanren_heji
                    },
                    type: 'post',
                    dataType: 'json',
                    success: function (res) {
                        layer.msg(res.msg);
                        sub.onclick = '';
                    }
                })
            }
        </script>
        <div id="light2" class="white_content">
            <div class="conts">
                <div class="input">
                    <span>诊断病情</span>
                    <input type="text" readonly name="bingqing" id="bingqing1" value="">
                </div>
                <div class="input">
                    <span>是否住院</span>
                    <select name="zhuyuan" id="zhuyuan1" disabled>
                        <option value="是">是</option>
                        <option value="否">否</option>
                    </select>
                </div>
                <div class="input">
                    <span>住院天数</span>
                    <input type="text" name="zhuyuan_date" readonly id="zhuyuan_date1" value="">
                </div>
                <div class="input">
                    <span>是否残疾</span>
                    <select name="canji" id="canji1" disabled>
                        <option value="是">是</option>
                        <option value="否">否</option>
                    </select>
                </div>
            </div>
            <div class="content">
                <input type="hidden" name="bid" class="sanid">
                <table class="layui-table" id="tabProducts1">
                    <tr style="background: #4e73df;color:#fff;">
                        <td style="width: 66px;">选择</td>
                        <td>序号</td>
                        <td>费用类型</td>
                        <td>金额</td>
                        <td>数量</td>
                        <td>总价</td>
                        <td>核价金额</td>
                        <td>备注</td>
                    </tr>
                    <tr>
                        <td><input type="checkbox" style="width: 15px;height: 15px;display: block;" name="id" readonly
                                   value=""/></td>
                        <td><input type="text" name="xuhao" value="1" readonly/></td>
                        <td><input type="text" name="leixing" readonly/></td>
                        <td><input type="text" name="price" readonly/></td>
                        <td><input type="text" readonly name="num"/></td>
                        <td><input type="text" readonly name="money"/></td>
                        <td><input type="text" readonly name="hejia"/></td>
                        <td><input type="text" readonly name="beizhu"/></td>
                    </tr>
                </table>
                <table class="layui-table" id="hes1">
                    <tr>
                        <td>小计</td>
                        <td><input type="text" readonly></td>
                        <td><input type="text" readonly></td>
                        <td><input type="text" readonly></td>
                        <td><input type="text" readonly></td>
                        <td><input type="text" readonly name="sren_money" id="sren_money" class="sren_money"></td>
                        <td><input type="text" readonly name="sren_hejia" id="sren_hejia" class="sren_hejia"></td>
                        <td><input type="text" readonly></td>
                    </tr>
                </table>
                <div class="conts" style="display: flex;justify-content: center;">
                    <div class="">
<!--                        <button style="margin: 1%;margin-top:20px;" type="button" onclick="closeDialog2()">关闭</button>-->
                        <!--                            <button style="margin: 1%;margin-top:20px;">修改</button>-->
                    </div>
                </div>
                </form>
            </div>
        </div>
        <div id="fade2" class="black_overlay"></div>
        <script type="text/javascript">
            function openDialogs2(id) {
                // 1. 先打开弹窗（显示加载中状态）
                var layerIndex = layer.open({
                    type: 1,
                    title: '加载中...',
                    content: `
                    <div style="
                      position: absolute;
                      top: 50%;
                      left: 50%;
                      transform: translate(-50%, -50%);
                      text-align: center;
                    ">
                      <i class="fa fa-spinner fa-pulse fa-3x fa-fw"></i>
                      <p style="margin-top: 10px">加载中...</p>
                    </div>
                  `,
                    area: ['80%', '80%'],
                    shadeClose: false // 禁止点击遮罩关闭
                });
                $.ajax({
                    url: "{:url('bushen/lisuan/sanrens')}",
                    data: {id: id},
                    type: 'post',
                    dataType: 'json',
                    success: function (res) {
                        if (res.status == true) {
                            var html = '';
                            if (res.data.renshang.length > 0) {
                                var html = '';
                                for (var i = 0; i < res.data.renshang.length; i++) {
                                    html += "<tr>" +
                                        "<td><input type='checkbox' style='width: 15px;height: 15px;display: block;' name='id' disabled value=" + res.data.renshang[i].id + "></td>" +
                                        "<td><input type='text' name='xuhao' readonly value=" + res.data.renshang[i].xuhao + "></td>" +
                                        // "<td><input type='text' name='type' readonly value=" + res.data.renshang[i].type + "></td>" +
                                        "<td><input type='text' name='leixing' readonly value=" + res.data.renshang[i].leixing + "></td>" +
                                        "<td><input type='text' name='price' readonly value=" + res.data.renshang[i].price + "></td>" +
                                        "<td><input type='text' name='num' readonly value=" + res.data.renshang[i].num + "></td>" +
                                        "<td><input type='text' name='money' readonly value=" + res.data.renshang[i].money + "></td>" +
                                        "<td><input type='text' name='hejia' readonly value=" + res.data.renshang[i].hejia + "></td>" +
                                        "<td><input type='text' name='beizhu' readonly value=" + res.data.renshang[i].beizhu + "></td>" +
                                        "</tr>";
                                }
                            } else {
                                html += "<tr>" +
                                    "<td><input type='checkbox' style='width: 15px;height: 15px;display: block;' name='id' disabled value=''></td>" +
                                    "<td><input type='text' name='xuhao' value='1' readonly></td>" +
                                    // "<td><input type='text' name='type' readonly value=''></td>" +
                                    "<td><input type='text' name='leixing' readonly value=''></td>" +
                                    "<td><input type='text' name='price' readonly value=''></td>" +
                                    "<td><input type='text' name='num' readonly value=''></td>" +
                                    "<td><input type='text' name='money' readonly value=''></td>" +
                                    "<td><input type='text' name='hejia' readonly value=''></td>" +
                                    "<td><input type='text' name='beizhu' readonly value=''></td>" +
                                    "</tr>";
                            }
                            $("#tabProducts1 tr").slice(1).remove();
                            $('#tabProducts1').append(html);
                            $('#bingqing1').val(res.data.sanren.bingqing);
                            $('#zhuyuan1').val(res.data.sanren.zhuyuan);
                            $('#zhuyuan_date1').val(res.data.sanren.zhuyuan_date);
                            $('#canji1').val(res.data.sanren.canji);
                            $('#sren_money').val(res.data.sanren.money);
                            $('#sren_hejia').val(res.data.sanren.hejia);
                            $('.sanid').val(res.data.sanren.id);
                            layer.title('详情', layerIndex); // 修改标题
                            $('#layui-layer' + layerIndex).find('.layui-layer-content').html($('#light2').html()); // 更新内容
                        }else{
                            layer.msg(res.msg || '数据加载失败', {icon: 2});
                        }
                    }
                })
            }

            function closeDialog2() {
                    document.getElementById('light2').style.display = 'none';
                    document.getElementById('fade2').style.display = 'none'
            }
        </script>
    </div>
    <script type="text/javascript">
        function test1(obj) {

            var div1 = document.getElementById("div2");
            if (div1.style.display == "block") {
                div1.style.display = "none";
            } else {
                div1.style.display = "block";
            }
        }
    </script>

</div>